package com.bridgeintelligent.tag.webserver.dim.query.service.thread;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.*;

/**
 * 定义线程池
 */
@Component
public class ThemeThreadPoolBean {

    @Bean("threadPool_theme")
    public Executor themeThreadPool() {
        ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("theme-%d").build();
        BlockingQueue<Runnable> blockingQueue = new LinkedBlockingQueue<>(Integer.MAX_VALUE);
        return new ThreadPoolExecutor(2, 4, 10, TimeUnit.SECONDS, blockingQueue, threadFactory);
    }
}
